package com.aspose.cells;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;

public class Worksheet {
   private int p = 1;
   private String q;
   private Cells r;
   private PaneCollection s;
   private Protection t;
   private WorksheetCollection u;
   private CommentCollection v;
   QueryTableCollection a;
   PivotTableCollection b;
   private zbmw w;
   int c = 1;
   private int x = 182;
   private PictureCollection y;
   private ListObjectCollection z;
   private TextBoxCollection A;
   private CheckBoxCollection B;
   private OleObjectCollection C;
   int d;
   private int D;
   private ChartCollection E;
   HyperlinkCollection e;
   private AutoFilter F;
   short f;
   private byte G;
   private ArrayList H;
   private zbnq I;
   zpr g = null;
   private zbcj J;
   ShapeCollection h;
   private ValidationCollection K;
   private ProtectedRangeCollection L;
   ErrorCheckOptionCollection i;
   private Outline M;
   private int N;
   private int O;
   private int P = 0;
   private int[] Q = new int[]{100, 60, 100};
   private boolean R = true;
   zakp j;
   private int S = 64;
   String k;
   double[] l;
   private ArrayList T;
   private byte[] U;
   ConditionalFormattingCollection m;
   private ArrayList V;
   private CustomPropertyCollection W;
   private SparklineGroupCollection X;
   private SmartTagSetting Y;
   znc n;
   ScenarioCollection o;

   public Protection getProtection() {
      if (this.t == null) {
         this.t = new Protection();
      }

      return this.t;
   }

   Protection a() {
      return this.t;
   }

   PaneCollection b() {
      if (this.s == null) {
         this.s = new PaneCollection(this);
      }

      return this.s;
   }

   public PaneCollection getPanes() {
      return this.s;
   }

   Worksheet(zbpx stringTable, WorksheetCollection sheets) {
      this.u = sheets;
      this.D = sheets.getCount();
      ++sheets.b;
      this.d = sheets.b;
      this.E = new ChartCollection(this);
      this.v = new CommentCollection(this);
      this.f = 1217;
      this.e = new HyperlinkCollection(this);
      this.r = new Cells(stringTable, this);
      this.K = new ValidationCollection(this);
      this.L = new ProtectedRangeCollection(this);
      this.M = new Outline();
      this.q = "";
      this.j = new zakp(false);
      this.j.a(true);
   }

   Worksheet(zbpx stringTable, WorksheetCollection sheets, String sheetName) {
      this.u = sheets;
      this.D = sheets.getCount();
      ++sheets.b;
      this.d = sheets.b;
      this.E = new ChartCollection(this);
      this.v = new CommentCollection(this);
      this.f = 1217;
      this.e = new HyperlinkCollection(this);
      this.r = new Cells(stringTable, this);
      this.K = new ValidationCollection(this);
      this.L = new ProtectedRangeCollection(this);
      this.M = new Outline();
      this.q = sheetName;
      this.j = new zakp(false);
      this.j.a(true);
   }

   WorksheetCollection c() {
      return this.u;
   }

   public Workbook getWorkbook() {
      return this.u.n();
   }

   public CommentCollection getComments() {
      return this.v;
   }

   public Cells getCells() {
      return this.r;
   }

   public QueryTableCollection getQueryTables() {
      if (this.a == null) {
         this.a = new QueryTableCollection();
      }

      return this.a;
   }

   public PivotTableCollection getPivotTables() {
      if (this.b == null) {
         this.b = new PivotTableCollection(this);
      }

      return this.b;
   }

   zbmw d() {
      if (null == this.w) {
         this.w = new zbmw(this);
      }

      return this.w;
   }

   int e() {
      return this.c;
   }

   void a(int var1) {
      this.c = var1;
   }

   void f() {
      this.r.k();
      int var2;
      if (this.v != null && this.v.getCount() > 0) {
         Comment var1 = null;

         for(var2 = this.v.getCount() - 1; var2 >= 0; --var2) {
            var1 = this.v.get(var2);
            if (var1.getRow() > 65535 || var1.getColumn() > 255) {
               this.getShapes().b(var1.getCommentShape());
            }
         }
      }

      int var6;
      if (this.e != null && this.e.getCount() > 0) {
         for(var6 = this.e.getCount() - 1; var6 >= 0; --var6) {
            CellArea var8 = this.e.get(var6).getArea();
            if (var8.StartRow <= 65535 && var8.StartColumn <= 255) {
               if (var8.EndRow > 65535) {
                  var8.EndRow = 65535;
                  if (var8.EndColumn > 255) {
                     var8.EndColumn = 255;
                  }

                  this.e.get(var6).a(var8);
               } else if (var8.EndColumn > 255) {
                  var8.EndColumn = 255;
                  this.e.get(var6).a(var8);
               }
            } else {
               this.e.removeAt(var6);
            }
         }
      }

      if (this.s != null && (this.s.b() > 65535 || this.s.c() > 255)) {
         if (this.h()) {
            this.unFreezePanes();
         } else {
            this.removeSplit();
         }
      }

      int var4;
      if (this.J != null && this.J.size() > 0) {
         for(var2 = 0; var2 < this.J.size(); ++var2) {
            zbci var3 = (zbci)this.J.get(0);

            for(var4 = var3.b().size() - 1; var4 >= 0; --var4) {
               CellArea var7 = (CellArea)var3.b().get(var4);
               if (var7.StartRow <= 65535 && var7.StartColumn <= 255) {
                  if (var7.EndRow > 65535) {
                     var7.EndRow = 65535;
                  }

                  if (var7.EndColumn > 255) {
                     var7.EndColumn = 255;
                  }

                  var3.b().set(var4, var7);
               } else {
                  if (var3.e() == var4) {
                     if (this.s != null) {
                        switch(var3.a()) {
                        case 0:
                           var3.a(this.s.b(), this.s.c());
                           break;
                        case 1:
                           var3.a(0, this.s.c());
                           break;
                        case 2:
                           var3.a(this.s.b(), 0);
                           break;
                        case 3:
                           var3.a(0, 0);
                        }
                     } else {
                        var3.a(0, 0);
                     }
                  }

                  if (var3.e() > var4) {
                     var3.c(var3.e() - 1);
                  }

                  var3.b().remove(var4);
               }
            }

            if (var3.c() > 65535) {
               var3.a((int)65535);
            }

            if (var3.d() > 255) {
               var3.b(255);
            }
         }
      }

      if (this.N > 65535) {
         this.N = 0;
      }

      if (this.O > 255) {
         this.O = 0;
      }

      if (this.K != null && this.K.getCount() > 0) {
         for(var6 = this.K.getCount() - 1; var6 >= 0; --var6) {
            ArrayList var10 = this.K.get(var6).getAreaList();

            for(int var9 = var10.size() - 1; var9 >= 0; --var9) {
               CellArea var13 = (CellArea)var10.get(var9);
               if (var13.StartRow <= 65535 && var13.StartColumn <= 255) {
                  if (var13.EndRow > 65535) {
                     var13.EndRow = 65535;
                     if (var13.EndColumn > 255) {
                        var13.EndColumn = 255;
                     }

                     var10.set(var9, var13);
                  } else if (var13.EndColumn > 255) {
                     var13.EndColumn = 255;
                     var10.set(var9, var13);
                  }
               } else {
                  var10.remove(var9);
               }
            }

            if (var10.size() == 0) {
               this.K.removeAt(var6);
            }
         }
      }

      if (this.m != null && this.m.getCount() > 0) {
         for(var6 = this.m.getCount() - 1; var6 >= 0; --var6) {
            FormatConditionCollection var11 = this.m.get(var6);
            ArrayList var12 = var11.b;

            for(var4 = var12.size() - 1; var4 >= 0; --var4) {
               CellArea var5 = (CellArea)var12.get(var4);
               if (var5.StartRow <= 65535 && var5.StartColumn <= 255) {
                  if (var5.EndRow > 65535) {
                     var5.EndRow = 65535;
                     if (var5.EndColumn > 255) {
                        var5.EndColumn = 255;
                     }

                     var12.set(var4, var5);
                  } else if (var5.EndColumn > 255) {
                     var5.EndColumn = 255;
                     var12.set(var4, var5);
                  }
               } else {
                  var12.remove(var4);
               }
            }

            if (var12.size() == 0) {
               this.m.removeAt(var6);
            }
         }
      }

   }

   public int getType() {
      return this.p;
   }

   public void setType(int value) {
      this.p = value;
   }

   public String getName() {
      return this.q;
   }

   public void setName(String value) {
      if (value != null && !"".equals(value)) {
         String var2 = this.a(value);
         Iterator var3 = this.u.iterator();

         while(var3.hasNext()) {
            Worksheet var4 = (Worksheet)var3.next();
            Iterator var5 = var4.E.iterator();

            while(var5.hasNext()) {
               Chart var6 = (Chart)var5.next();
               String var7 = var6.getPivotSource();
               if (var7 != null) {
                  int var8 = var7.indexOf("!");
                  if (var8 != -1) {
                     String var9 = var7.substring(0, 0 + var8);
                     if (var9.toUpperCase().equals(this.q.toUpperCase())) {
                        String var10 = var7.substring(var8);
                        var6.setPivotSource(var2 + var10);
                     }
                  }
               }
            }
         }

         this.q = var2;
         this.u.e();
         this.u.ad();
      }
   }

   String a(String var1) {
      if (var1.length() >= 32) {
         throw new CellsException(6, "The max length of the sheet name is 31");
      } else {
         int var2 = 0;

         while(var2 < var1.length()) {
            switch(var1.charAt(var2)) {
            case '*':
            case '/':
            case ':':
            case '?':
            case '[':
            case '\\':
            case ']':
               throw new CellsException(6, "Worksheet name could not contain any following characters :  : \\ / ? * [  or ]");
            default:
               ++var2;
            }
         }

         if (!com.aspose.cells.b.a.zv.b(var1.toUpperCase(), this.q.toUpperCase())) {
            for(var2 = 0; var2 < this.u.getCount(); ++var2) {
               String var3 = this.u.get(var2).getName();
               if (com.aspose.cells.b.a.zv.b(var3.toUpperCase(), var1.toUpperCase())) {
                  throw new CellsException(6, "The same worksheet name already exists");
               }
            }
         }

         return var1;
      }
   }

   void b(String var1) {
      this.q = var1;
   }

   int g() {
      return this.x;
   }

   void b(int var1) {
      this.x = var1;
   }

   public boolean getShowFormulas() {
      return (this.x & '\uffff' & 1) != 0;
   }

   public void setShowFormulas(boolean value) {
      if (value) {
         this.x |= 1;
      } else {
         this.x &= 65534;
      }

   }

   public boolean isGridlinesVisible() {
      return (this.x & '\uffff' & 2) != 0;
   }

   public void setGridlinesVisible(boolean value) {
      if (value) {
         this.x |= 2;
      } else {
         this.x &= 65533;
      }

   }

   public boolean isRowColumnHeadersVisible() {
      return (this.x & '\uffff' & 4) != 0;
   }

   public void setRowColumnHeadersVisible(boolean value) {
      if (value) {
         this.x |= 4;
      } else {
         this.x &= 65531;
      }

   }

   boolean h() {
      return (this.x & '\uffff' & 8) != 0;
   }

   void a(boolean var1) {
      if (var1) {
         this.x |= 8;
      } else {
         this.x &= 65527;
      }

   }

   void b(boolean var1) {
      if (var1) {
         this.x &= 65279;
      } else {
         this.x |= 256;
      }

   }

   public boolean getDisplayZeros() {
      return (this.x & '\uffff' & 16) != 0;
   }

   public void setDisplayZeros(boolean value) {
      if (value) {
         this.x |= 16;
      } else {
         this.x &= 65519;
      }

   }

   public boolean getDisplayRightToLeft() {
      return (this.x & '\uffff' & 64) != 0;
   }

   public void setDisplayRightToLeft(boolean value) {
      if (value) {
         this.x |= 64;
      } else {
         this.x &= 65471;
      }

   }

   public boolean isOutlineShown() {
      return (this.x & '\uffff' & 128) != 0;
   }

   public void setOutlineShown(boolean value) {
      if (value) {
         this.x |= 128;
      } else {
         this.x &= 65407;
      }

   }

   public boolean isSelected() {
      return (this.x & '\uffff' & 512) != 0;
   }

   public void setSelected(boolean value) {
      if (value) {
         this.x |= 1536;
      } else {
         this.x &= 65023;
      }

   }

   public void freezePanes(int row, int column, int freezedRows, int freezedColumns) {
      zakq.a(row, column);
      if (freezedRows >= 0 && freezedColumns >= 0) {
         if (row == 0 && column == 0) {
            throw new IllegalArgumentException("Row index and column index cannot all be zero.");
         } else if (freezedRows == 0 && freezedColumns == 0) {
            throw new IllegalArgumentException("Number of freezed rows and number of freezed columns cannot all be zero.");
         } else {
            if (this.s == null) {
               this.s = new PaneCollection(this);
               this.b(false);
            } else {
               boolean var5 = this.h();
               if (!var5) {
                  this.b(true);
               }
            }

            this.s.c(row, column, freezedRows, freezedColumns);
            this.a(true);
         }
      } else {
         throw new IllegalArgumentException("Row index and column index cannot all be zero.");
      }
   }

   public int[] getFreezedPanes() {
      boolean var1 = false;
      boolean var2 = false;
      boolean var3 = false;
      boolean var4 = false;
      if (this.h() && this.s != null) {
         int var6 = this.s.d() == 0 ? 0 : this.N + this.s.d();
         int var7 = this.s.e() == 0 ? 0 : this.O + this.s.e();
         int var8 = this.s.d();
         int var9 = this.s.e();
         int[] var5 = new int[]{var6, var7, var8, var9};
         return var5;
      } else {
         return null;
      }
   }

   public void split() {
      String var1 = this.getActiveCell();
      this.s = new PaneCollection(this);
      this.a(false);
      this.s.a(var1);
   }

   public void freezePanes(String cellName, int freezedRows, int freezedColumns) {
      byte var4 = 0;
      byte var5 = 0;
      int[] var6 = new int[]{var4};
      int[] var7 = new int[]{var5};
      CellsHelper.a(cellName, var6, var7);
      int var8 = var6[0];
      int var9 = var7[0];
      this.freezePanes(var8, var9, freezedRows, freezedColumns);
   }

   public void unFreezePanes() {
      if (this.h()) {
         this.s = null;
         this.a(false);
         this.b(true);
         if (this.J != null) {
            for(int var1 = this.J.size() - 1; var1 >= 0; --var1) {
               zbci var2 = (zbci)this.J.get(var1);
               if (var2.a() != 3) {
                  this.J.remove(var1);
               }
            }
         }
      }

   }

   public void removeSplit() {
      if (!this.h()) {
         this.s = null;
         if (this.J != null) {
            for(int var1 = this.J.size() - 1; var1 >= 0; --var1) {
               zbci var2 = (zbci)this.J.get(var1);
               if (var2.a() != 3) {
                  this.J.remove(var1);
               }
            }
         }

         this.b(true);
      } else {
         this.b(false);
      }

   }

   public PictureCollection getPictures() {
      if (this.y == null) {
         this.y = new PictureCollection(this.getShapes());
      }

      return this.y;
   }

   PictureCollection i() {
      return this.y;
   }

   public ListObjectCollection getListObjects() {
      if (this.z == null) {
         this.z = new ListObjectCollection(this);
      }

      return this.z;
   }

   ListObjectCollection j() {
      return this.z;
   }

   public TextBoxCollection getTextBoxes() {
      if (this.A == null) {
         this.A = new TextBoxCollection(this.getShapes());
      }

      return this.A;
   }

   public CheckBoxCollection getCheckBoxes() {
      if (this.B == null) {
         this.B = new CheckBoxCollection(this.getShapes());
      }

      return this.B;
   }

   public OleObjectCollection getOleObjects() {
      if (this.C == null) {
         this.C = new OleObjectCollection(this.getShapes());
      }

      return this.C;
   }

   OleObjectCollection k() {
      return this.C;
   }

   int l() {
      return this.d;
   }

   void c(int var1) {
      this.d = var1;
      if (var1 > this.u.b) {
         this.u.b = var1;
      }

   }

   int m() {
      return this.D;
   }

   void d(int var1) {
      this.D = var1;
   }

   public ChartCollection getCharts() {
      return this.E;
   }

   public HorizontalPageBreakCollection getHorizontalPageBreaks() {
      return this.r.c();
   }

   public VerticalPageBreakCollection getVerticalPageBreaks() {
      return this.r.d();
   }

   public void addPageBreaks(String cellName) {
      byte var2 = 0;
      byte var3 = 0;
      int[] var4 = new int[]{var2};
      int[] var5 = new int[]{var3};
      CellsHelper.a(cellName, var4, var5);
      int var6 = var4[0];
      int var7 = var5[0];
      this.getHorizontalPageBreaks().add(var6, var7);
      this.getVerticalPageBreaks().add(var6, var7);
   }

   public HyperlinkCollection getHyperlinks() {
      return this.e;
   }

   private void a(Worksheet var1, CopyOptions var2) throws Exception {
      this.removeAllDrawingObjects();
      if (var1.p == 2) {
         Chart var3 = new Chart(this);
         Chart var4 = var1.E.get(0);
         var3.getChartObject().a(var4.getChartObject(), var2);
         this.E.a(var3);
      } else {
         if (var1.h != null && var1.h.getCount() != 0) {
            this.getShapes().a(var1.getShapes(), var2);
         }

         if (var1.X != null && var1.X.getCount() != 0) {
            this.getSparklineGroupCollection().a(var1.getSparklineGroupCollection(), var2);
         }

      }
   }

   public void copy(Worksheet sourceSheet) throws Exception {
      CopyOptions var2 = new CopyOptions(false);
      var2.setCopyNames(true);
      this.copy(sourceSheet, var2);
      this.setSelected(this.u.getActiveSheetIndex() == this.getIndex());
   }

   public void copy(Worksheet sourceSheet, CopyOptions copyOption) throws Exception {
      if (sourceSheet != null) {
         if (this != sourceSheet) {
            if (copyOption == null) {
               copyOption = new CopyOptions(false);
            }

            if (copyOption.getCopyInvalidFormulasAsValues()) {
               copyOption.f = new HashMap();

               int var3;
               for(var3 = 0; var3 < sourceSheet.u.q().getCount(); ++var3) {
                  zur var4 = sourceSheet.u.q().b(var3);
                  if ((var4.a & '\uffff') != sourceSheet.u.u() || var4.b != var4.c || (var4.b & '\uffff') != sourceSheet.getIndex()) {
                     copyOption.f.put(var3, var3);
                  }
               }

               copyOption.g = new HashMap();

               for(var3 = 0; var3 < sourceSheet.u.getNames().getCount(); ++var3) {
                  Name var14 = sourceSheet.u.getNames().get(var3);
                  if (var14.b() != null) {
                     if (zyo.a(var14.b(), -1, -1, sourceSheet.u, copyOption.f, copyOption.g)) {
                        copyOption.g.put(var3, true);
                     } else {
                        copyOption.g.put(var3, false);
                     }
                  }
               }
            }

            if (this.u == sourceSheet.u && sourceSheet.g != null && sourceSheet.g.d != null) {
               this.g = new zpr(this);
               this.g.d = sourceSheet.g.d;
               com.aspose.cells.b.a.a.ze.a(this.g.n, (Collection)sourceSheet.g.n);
               com.aspose.cells.b.a.a.ze.a(this.g.p, (Collection)sourceSheet.g.p);
               com.aspose.cells.b.a.a.ze.a(this.g.q, (Collection)sourceSheet.g.q);
            }

            this.r = new Cells(this.u.g, this);
            this.K = new ValidationCollection(this);
            this.L = new ProtectedRangeCollection(this);
            this.M = new Outline();
            if (copyOption.i == null) {
               copyOption.a(sourceSheet, this);
            }

            if (this.p != 2) {
               if (!copyOption.a && copyOption.getCopyNames()) {
                  HashMap var15 = new HashMap();
                  int var16 = sourceSheet.u.getNames().getCount();
                  ArrayList var5 = new ArrayList();

                  int var9;
                  for(int var6 = 0; var6 < var16; ++var6) {
                     Name var7 = sourceSheet.u.getNames().get(var6);
                     String var8 = var7.getText();
                     var9 = var7.getSheetIndex() - 1;
                     int var10 = 0;
                     boolean var11 = false;
                     int var12;
                     if (var9 == -1) {
                        var9 = var7.o();
                        if (var9 == sourceSheet.getIndex()) {
                           var11 = true;
                           var10 = this.getIndex();
                           if (this.u != sourceSheet.u) {
                              var12 = this.u.getNames().a(var7.getText(), -1, false);
                              if (var12 == -1) {
                                 var10 = -1;
                              } else if (var12 < var16 && sourceSheet.u.getNames().a(var7.getText(), var9, false) != -1) {
                                 var11 = false;
                              }
                           }
                        } else if (var7.getRefersTo() == null) {
                           var12 = this.u.getNames().a(var7.getText(), -1, false);
                           if (var12 == -1) {
                              var11 = true;
                              var10 = -1;
                           }
                        }
                     } else if (var9 == sourceSheet.getIndex()) {
                        var11 = true;
                        var10 = this.getIndex();
                     }

                     if (var11) {
                        var12 = this.u.getNames().a(var10, var8);
                        Name var13 = this.c().getNames().get(var12);
                        if (!var5.contains(var13)) {
                           var13.b(var7);
                           var15.put(var6, var12);
                           com.aspose.cells.b.a.a.ze.a(var5, (Object)var13);
                        }
                     }
                  }

                  copyOption.d = var15;
                  HashMap var18 = copyOption.i;
                  int var19 = this.c().q().f(this.c().u(), 65535, 65535);
                  if (var19 == -1) {
                     var19 = this.c().q().b(this.c().u(), 65535, 65535);
                  }

                  HashMap var20 = copyOption.k;

                  for(var9 = 0; var9 < var5.size(); ++var9) {
                     Name var21 = (Name)var5.get(var9);
                     byte[] var22 = var21.b();
                     if (var22 != null && !zyo.a(var18, var15, sourceSheet, this, var20, var19, -1, -1, var22)) {
                        var21.setRefersTo((String)null);
                     }
                  }
               }

               if (sourceSheet.z != null) {
                  this.z = new ListObjectCollection(this);
                  this.z.a(sourceSheet.z, copyOption);
               }

               if (sourceSheet.Y != null) {
                  this.Y = new SmartTagSetting(this);
                  this.Y.a(sourceSheet.Y);
               }

               this.O = sourceSheet.O;
               this.N = sourceSheet.N;
               this.R = sourceSheet.R;
               this.p = sourceSheet.p;
               if (sourceSheet.F != null) {
                  this.getAutoFilter().a(sourceSheet.F);
               } else {
                  this.F = null;
               }

               if (sourceSheet.m != null) {
                  this.m = new ConditionalFormattingCollection(this);
                  this.m.a(sourceSheet.m, copyOption);
               } else {
                  this.m = null;
               }

               if (sourceSheet.K.getCount() > 0) {
                  this.K.clear();
                  this.K.a(sourceSheet.K, copyOption);
               }

               if (sourceSheet.L.getCount() > 0) {
                  this.L.clear();
                  this.L.a(sourceSheet.L);
               }

               if (sourceSheet.s != null) {
                  this.s = new PaneCollection(this);
                  this.s.a(sourceSheet.s);
               } else {
                  this.s = null;
               }

               this.a(sourceSheet);
               if (!copyOption.a && this.u == sourceSheet.u && this.u.getActiveSheetIndex() == sourceSheet.getIndex()) {
                  this.u.setActiveSheetIndex(this.getIndex());
               }

               if (sourceSheet.t != null) {
                  this.t = new Protection();
                  this.t.copy(sourceSheet.t);
               } else {
                  this.t = null;
               }

               this.r.a(sourceSheet.r, copyOption);
               if (sourceSheet.e.getCount() > 0) {
                  this.e.a(sourceSheet.e);
               }

               if (sourceSheet.b != null && sourceSheet.b.getCount() != 0) {
                  this.b = new PivotTableCollection(this);
                  this.getPivotTables().a(sourceSheet.b);
               } else {
                  this.b = null;
               }

               this.M = sourceSheet.M;
            }

            this.b(sourceSheet);
            if (copyOption.c == 6) {
               this.setSelected(false);
            }

            this.a(sourceSheet, copyOption);
            if (copyOption.a) {
               this.d = sourceSheet.d;
               this.k = sourceSheet.k;
               if (sourceSheet.g != null) {
                  this.g = sourceSheet.g;
                  this.g.a = this;
               }
            } else if (sourceSheet.u == this.u) {
               if (this.u.n().getSettings().getEnableMacros()) {
                  VbaProject var17 = this.u.ag();
                  if (var17 != null) {
                     var17.a(sourceSheet.getCodeName(), this.getCodeName());
                  }
               }

               if (sourceSheet.g != null && this.g == null) {
                  this.g = new zpr(this);
               }
            } else {
               this.k = sourceSheet.k;
            }

         }
      }
   }

   private void a(Worksheet var1) {
      this.J = null;
      if (var1.J != null && var1.J.size() > 0) {
         this.J = new zbcj(this);

         for(int var2 = 0; var2 < var1.J.size(); ++var2) {
            zbci var3 = (zbci)var1.J.get(var2);
            zbci var4 = new zbci(var3.a() & 255);
            var4.a(var3);
            com.aspose.cells.b.a.a.ze.a(this.J, (Object)var4);
         }
      }

   }

   private void b(Worksheet var1) {
      this.G = var1.G;
      this.P = var1.P;
      System.arraycopy(var1.Q, 0, this.Q, 0, this.Q.length);
      this.j.f(var1.j);
      this.x = var1.x;
      this.f = var1.f;
      this.U = var1.U;
   }

   public void autoFitColumn(int columnIndex, int firstRow, int lastRow) throws Exception {
      zakq.b(columnIndex);
      zakq.b(firstRow, lastRow);
      zko.a(this.r, firstRow, lastRow, columnIndex, columnIndex, (AutoFitterOptions)null);
   }

   public void autoFitColumns() throws Exception {
      zko.a(this.r, 0, 1048575, 0, 16383, (AutoFitterOptions)null);
   }

   public void autoFitColumns(AutoFitterOptions options) throws Exception {
      zko.a(this.r, 0, 1048575, 0, 16383, options);
   }

   public void autoFitColumn(int columnIndex) throws Exception {
      zakq.b(columnIndex);
      zko.a(this.r, 0, 1048575, columnIndex, columnIndex, (AutoFitterOptions)null);
   }

   public void autoFitColumns(int firstColumn, int lastColumn) throws Exception {
      zakq.b(firstColumn);
      zakq.b(lastColumn);
      zko.a(this.r, 0, 1048575, firstColumn, lastColumn, (AutoFitterOptions)null);
   }

   public void autoFitColumns(int firstColumn, int lastColumn, AutoFitterOptions options) throws Exception {
      zakq.b(firstColumn);
      zakq.b(lastColumn);
      zko.a(this.r, 0, 1048575, firstColumn, lastColumn, options);
   }

   public void autoFitColumns(int firstRow, int firstColumn, int lastRow, int lastColumn) throws Exception {
      zakq.b(firstColumn);
      zakq.b(lastColumn);
      zko.a(this.r, firstRow, lastRow, firstColumn, lastColumn, (AutoFitterOptions)null);
   }

   public void autoFitColumns(int firstRow, int firstColumn, int lastRow, int lastColumn, AutoFitterOptions options) throws Exception {
      zakq.b(firstColumn);
      zakq.b(lastColumn);
      zko.a(this.r, firstRow, lastRow, firstColumn, lastColumn, options);
   }

   public void autoFitRow(int rowIndex, int firstColumn, int lastColumn) throws Exception {
      zakq.a(rowIndex);
      zakq.c(firstColumn, lastColumn);
      this.autoFitRow(rowIndex, rowIndex, firstColumn, lastColumn);
   }

   public void autoFitRow(int rowIndex, int firstColumn, int lastColumn, AutoFitterOptions options) throws Exception {
      zakq.a(rowIndex);
      zakq.c(firstColumn, lastColumn);
      zbaw.a(this.r, rowIndex, rowIndex, firstColumn, lastColumn, options);
   }

   public void autoFitRows() throws Exception {
      if (this.r.getRows().getCount() != 0) {
         Row var1 = this.r.getRows().getRowByIndex(this.r.getRows().getCount() - 1);
         AutoFitterOptions var2 = new AutoFitterOptions();
         zbaw.a(this.r, 0, var1.getIndex(), 0, this.r.b((short)0), var2);
      }
   }

   public void autoFitRows(boolean onlyAuto) throws Exception {
      if (this.r.getRows().getCount() != 0) {
         Row var2 = this.r.getRows().getRowByIndex(this.r.getRows().getCount() - 1);
         AutoFitterOptions var3 = new AutoFitterOptions();
         var3.setOnlyAuto(onlyAuto);
         zbaw.a(this.r, 0, var2.getIndex(), 0, this.r.b((short)0), var3);
      }
   }

   public void autoFitRows(AutoFitterOptions options) throws Exception {
      if (this.r.getRows().getCount() != 0) {
         Row var2 = this.r.getRows().getRowByIndex(this.r.getRows().getCount() - 1);
         zbaw.a(this.r, 0, var2.getIndex(), 0, this.r.b((short)0), options);
      }
   }

   public void autoFitRows(int startRow, int endRow) throws Exception {
      zakq.a(startRow);
      zakq.a(endRow);
      AutoFitterOptions var3 = new AutoFitterOptions();
      var3.a = true;
      zbaw.a(this.r, startRow, endRow, 0, 16383, var3);
   }

   public void autoFitRows(int startRow, int endRow, AutoFitterOptions options) throws Exception {
      zakq.a(startRow);
      zakq.a(endRow);
      options.a = true;
      zbaw.a(this.r, startRow, endRow, 0, 16383, options);
   }

   public void autoFitRow(int startRow, int endRow, int startColumn, int endColumn) throws Exception {
      zakq.a(startRow, startColumn, endRow, endColumn);
      AutoFitterOptions var5 = new AutoFitterOptions();
      var5.a = startColumn == 0 && endColumn == 16383;
      zbaw.a(this.r, startRow, endRow, startColumn, endColumn, var5);
   }

   public void autoFitRow(int rowIndex) throws Exception {
      zakq.a(rowIndex);
      AutoFitterOptions var2 = new AutoFitterOptions();
      var2.a = true;
      zbaw.a(this.r, rowIndex, rowIndex, 0, 16383, var2);
   }

   public PageSetup getPageSetup() {
      return this.p == 2 && this.E.getCount() > 0 ? this.E.get(0).getPageSetup() : this.r.i();
   }

   public AutoFilter getAutoFilter() {
      if (this.F == null) {
         this.F = new AutoFilter(this, this);
      }

      return this.F;
   }

   public void removeAutoFilter() {
      this.F = null;
   }

   public boolean hasAutofilter() {
      if (this.F == null) {
         return false;
      } else {
         return this.F.f() != 0;
      }
   }

   boolean n() {
      return (this.f & 16384) != 0;
   }

   public boolean getTransitionEvaluation() {
      return (this.f & 16384) != 0;
   }

   public void setTransitionEvaluation(boolean value) {
      if (value) {
         this.f = (short)(this.f | 16384);
      } else {
         this.f &= -16385;
      }

   }

   public boolean getTransitionEntry() {
      return (this.f & 8192) != 0;
   }

   public void setTransitionEntry(boolean value) {
      if (value) {
         this.f = (short)(this.f | 8192);
      } else {
         this.f &= -8193;
      }

   }

   byte o() {
      return this.G;
   }

   void a(byte var1) {
      this.G = var1;
   }

   public int getVisibilityType() {
      switch(this.G) {
      case 0:
         return 0;
      case 1:
         return 1;
      case 2:
         return 2;
      default:
         return 0;
      }
   }

   public void setVisibilityType(int value) {
      if (value == 0) {
         this.G = 0;
         this.u.setActiveSheetIndex(this.getIndex());
      } else if (this.G == 0) {
         int var2 = -1;

         int var3;
         for(var3 = this.getIndex() + 1; var3 < this.u.getCount(); ++var3) {
            if (this.u.get(var3).isVisible()) {
               var2 = var3;
               break;
            }
         }

         if (var2 == -1) {
            for(var3 = this.getIndex() - 1; var3 >= 0; --var3) {
               if (this.u.get(var3).isVisible()) {
                  var2 = var3;
                  break;
               }
            }
         }

         if (var2 == -1) {
            throw new CellsException(10, "A workbook must contain at least a visible worksheet");
         }

         this.G = (byte)value;
         this.setSelected(false);
         this.u.b(var2);
         if (this.u.C() == this.getIndex()) {
            this.u.l(var2);
         }
      } else {
         this.G = (byte)value;
      }

   }

   public void setVisible(boolean isVisible, boolean ignoreError) {
      if (ignoreError) {
         if (isVisible) {
            this.G = 0;
         } else {
            this.G = 1;
            this.setSelected(false);
         }
      } else {
         this.setVisible(isVisible);
      }

   }

   public boolean isVisible() {
      return this.G == 0;
   }

   public void setVisible(boolean value) {
      if (this.isVisible() != value) {
         if (value) {
            this.G = 0;
            this.u.setActiveSheetIndex(this.getIndex());
         } else {
            int var2 = -1;

            int var3;
            for(var3 = this.getIndex() + 1; var3 < this.u.getCount(); ++var3) {
               if (this.u.get(var3).isVisible()) {
                  var2 = var3;
                  break;
               }
            }

            if (var2 == -1) {
               for(var3 = this.getIndex() - 1; var3 >= 0; --var3) {
                  if (this.u.get(var3).isVisible()) {
                     var2 = var3;
                     break;
                  }
               }
            }

            if (var2 == -1) {
               throw new CellsException(10, "A workbook must contain at least a visible worksheet");
            }

            this.G = 1;
            this.setSelected(false);
            if (this.u.getActiveSheetIndex() == this.getIndex()) {
               this.u.b(var2);
            }

            if (this.u.C() == this.getIndex()) {
               this.u.l(var2);
            }
         }

      }
   }

   void a(boolean var1, boolean var2) {
      if (var1) {
         this.G = 0;
      } else if (var2) {
         this.G = 2;
      } else {
         this.G = 1;
      }

   }

   boolean p() {
      return this.G == 2;
   }

   ArrayList q() {
      return this.H;
   }

   void a(ArrayList var1) {
      this.H = var1;
   }

   zbnq r() {
      return this.I;
   }

   void a(zbnq var1) {
      this.I = var1;
   }

   zbcj s() {
      return this.J;
   }

   void a(zbcj var1) {
      this.J = var1;
   }

   public void selectRange(int startRow, int startColumn, int totalRows, int totalColumns, boolean removeOthers) {
      if (this.J == null) {
         this.J = new zbcj(this);
         zbci var6 = new zbci(3);
         var6.a(startRow, startColumn, totalRows, totalColumns, removeOthers);
         com.aspose.cells.b.a.a.ze.a(this.J, (Object)var6);
      } else {
         this.J.a(startRow, startColumn, totalRows, totalColumns, removeOthers);
      }

   }

   public ShapeCollection getShapes() {
      if (this.h == null) {
         this.h = new ShapeCollection(this.u, this, this.u.Q(), this, -1);
      }

      return this.h;
   }

   ShapeCollection t() {
      return this.h;
   }

   void a(ShapeCollection var1) {
      this.h = var1;
   }

   private void g(int var1) {
      Protection var2 = this.getProtection();
      switch(var1) {
      case 0:
         var2.setAllowEditingContent(false);
         var2.setAllowEditingObject(false);
         var2.setAllowEditingScenario(false);
         break;
      case 1:
         var2.setAllowEditingContent(false);
         break;
      case 2:
         var2.setAllowEditingObject(false);
         break;
      case 3:
         var2.setAllowEditingScenario(false);
      }

   }

   public void protect(int type) {
      if (this.t == null || (this.t.b() & '\uffff') == 0) {
         this.g(type);
      }

   }

   public void protect(int type, String password, String oldPassword) {
      if (this.t == null || this.t.a(oldPassword)) {
         this.g(type);
         this.getProtection().a(zsw.a(password));
      }
   }

   public void unprotect() {
      this.unprotect((String)null);
   }

   public void unprotect(String password) {
      if (this.t != null) {
         if (this.t.a(password)) {
            this.t = null;
         } else {
            throw new CellsException(8, "Invalid password for unprotecting the worksheet.");
         }
      }
   }

   public void copyConditionalFormatting(int sourceRow, int sourceColumn, int destRow, int destColumn) {
      zakq.a(sourceRow, sourceColumn);
      zakq.a(destRow, destColumn);
      if (this.m != null) {
         this.m.a(sourceRow, sourceColumn, destRow, destColumn);
      }

   }

   public int getIndex() {
      return this.D;
   }

   public void moveTo(int index) {
      if (index != this.D) {
         this.u.a(this.D, index);
      }

      for(int var2 = 0; var2 < this.u.getCount(); ++var2) {
         Worksheet var3 = this.u.get(var2);
         var3.D = var2;
         if (var3.isSelected()) {
            this.u.setActiveSheetIndex(var2);
         }
      }

   }

   public boolean isProtected() {
      return this.t != null && !this.t.getAllowEditingContent();
   }

   public ValidationCollection getValidations() {
      return this.K;
   }

   public ProtectedRangeCollection getAllowEditRanges() {
      return this.L;
   }

   public ErrorCheckOptionCollection getErrorCheckOptions() {
      if (this.i == null) {
         this.i = new ErrorCheckOptionCollection(this);
      }

      return this.i;
   }

   public Outline getOutline() {
      return this.M;
   }

   public int getFirstVisibleRow() {
      return this.N;
   }

   public void setFirstVisibleRow(int value) {
      this.N = value;
   }

   public int getFirstVisibleColumn() {
      return this.O;
   }

   public void setFirstVisibleColumn(int value) {
      zakq.b(value);
      this.O = value;
   }

   public int replace(String oldString, String newString) {
      int var3 = 0;

      for(int var4 = 0; var4 < this.r.getRows().getCount(); ++var4) {
         Row var5 = this.r.getRows().getRowByIndex(var4);

         for(int var6 = 0; var6 < var5.a(); ++var6) {
            Cell var7 = var5.getCellByIndex(var6);
            zfv var8 = var7.c.d();
            if (var8.c == 4 && ((String)var8.d).indexOf(oldString) != -1) {
               var7.putValue(com.aspose.cells.b.a.zv.a((String)var8.d, oldString, newString));
               ++var3;
            }
         }
      }

      return var3;
   }

   int[] u() {
      return this.Q;
   }

   public int getZoom() {
      switch(this.P) {
      case 0:
         return this.Q[0];
      case 1:
         return this.Q[1];
      case 2:
         return this.Q[2];
      default:
         return 100;
      }
   }

   public void setZoom(int value) {
      if (value >= 10 && value <= 400) {
         switch(this.P) {
         case 0:
            this.Q[0] = value;
            break;
         case 1:
            this.Q[1] = value;
            break;
         case 2:
            this.Q[2] = value;
         }
      }

   }

   public int getViewType() {
      return this.P;
   }

   public void setViewType(int value) {
      this.P = value;
   }

   public boolean isPageBreakPreview() {
      return this.P == 1;
   }

   public void setPageBreakPreview(boolean value) {
      if (value) {
         this.P = 1;
      } else {
         this.P = 0;
      }

   }

   public boolean isRulerVisible() {
      return this.R;
   }

   public void setRulerVisible(boolean value) {
      this.R = value;
   }

   public void removeAllDrawingObjects() {
      if (this.y != null) {
         this.y.clear();
      }

      if (this.v != null) {
         this.v.clear();
      }

      if (this.E != null) {
         this.E.c();
      }

      if (this.A != null) {
         this.A.clear();
      }

      if (this.B != null) {
         this.B.clear();
      }

      if (this.C != null) {
         this.C.clear();
      }

      if (this.h != null) {
         this.h.clear();
      }

   }

   public ArrayList getSelectedRanges() {
      if (this.J != null && this.J.size() != 0) {
         ArrayList var1 = new ArrayList();

         for(int var2 = 0; var2 < this.J.size(); ++var2) {
            zbci var3 = (zbci)this.J.get(var2);

            for(int var4 = 0; var4 < var3.b().size(); ++var4) {
               CellArea var5 = (CellArea)var3.b().get(var4);
               Range var6 = this.r.createRange(var5.StartRow, var5.StartColumn, var5.EndRow - var5.StartRow + 1, var5.EndColumn - var5.StartColumn + 1);
               com.aspose.cells.b.a.a.ze.a(var1, (Object)var6);
            }
         }

         return var1;
      } else {
         return null;
      }
   }

   public Color getTabColor() {
      return this.j.a() ? Color.getEmpty() : this.j.b(this.u.n());
   }

   public void setTabColor(Color value) {
      if (com.aspose.cells.a.c.zh.a(value)) {
         this.j.a(true);
      } else {
         this.j.a(2, value.toArgb());
      }

   }

   void e(int var1) {
      if (var1 >= 64) {
         this.j.a(true);
      } else {
         this.j.a(3, var1);
      }

   }

   int v() {
      if (this.j.a()) {
         return 64;
      } else {
         boolean var1 = false;
         boolean[] var2 = new boolean[]{var1};
         int var3 = this.j.a(this.u, 64, var2);
         var1 = var2[0];
         return var3;
      }
   }

   Color w() {
      return this.S >= 64 ? Color.getEmpty() : this.u.m().a(this.S);
   }

   void a(Color var1) {
      int var2 = this.u.m().a(var1);
      if (var2 == -1) {
         throw new CellsException(6, "This color is not in the palette. Please add it to palette first.");
      } else {
         this.S = var2;
      }
   }

   int x() {
      return this.S;
   }

   void f(int var1) {
      this.S = var1;
   }

   public void clearComments() {
      if (this.v != null) {
         this.v.clear();
      }

   }

   public String getCodeName() {
      if (this.k == null || "".equals(this.k)) {
         boolean var1 = false;

         for(int var2 = 0; var2 < this.c().getCount(); ++var2) {
            if (this.c().get(var2).k != null && !"".equals(this.c().get(var2).k)) {
               var1 = true;
               break;
            }
         }

         if (!var1) {
            return "Sheet" + (this.getIndex() + 1);
         }

         String var8 = null;
         int var3 = 0;

         for(int var4 = 0; var4 < this.c().getCount(); ++var4) {
            if (this.c().get(var4).k == null || "".equals(this.c().get(var4).k)) {
               boolean var5;
               do {
                  ++var3;
                  var8 = "Sheet" + var3;
                  var5 = false;

                  for(int var6 = 0; var6 < this.c().getCount(); ++var6) {
                     if (var6 != this.getIndex()) {
                        String var7 = this.c().get(var6).k;
                        if (var7 != null && com.aspose.cells.b.a.zv.b(var7.toUpperCase(), var8.toUpperCase())) {
                           var5 = true;
                           break;
                        }
                     }
                  }
               } while(var5);

               this.u.get(var4).k = var8;
            }
         }
      }

      return this.k;
   }

   double[] y() {
      if (this.l == null) {
         this.l = zatm.a(this);
      }

      return this.l;
   }

   void b(ArrayList var1) {
      this.T = var1;
   }

   public void setBackground(byte[] pictureData) {
      this.T = null;
      this.U = pictureData;
   }

   public byte[] getBackgroundImage() throws Exception {
      if (this.U != null) {
         return this.U;
      } else if (this.T == null) {
         return null;
      } else {
         byte[] var1 = (byte[])((byte[])this.T.get(0));
         int var2 = com.aspose.cells.b.a.zc.e(var1, 16) & '\uffff';
         int var3 = com.aspose.cells.b.a.zc.e(var1, 18) & '\uffff';
         int var4 = var2 * 3;
         int var5 = var4 % 4;
         if (var5 != 0) {
            var5 = 4 - var5;
            int var10000 = var4 + var5;
         }

         com.aspose.cells.b.a.b.za var6 = new com.aspose.cells.b.a.b.za(var2, var3);
         int var7 = 24;
         int var11 = 1;

         for(int var12 = var3 - 1; var12 >= 0; --var12) {
            for(int var13 = 0; var13 < var2; ++var13) {
               if (var7 >= var1.length) {
                  var1 = (byte[])((byte[])this.T.get(var11++));
                  var7 = 4;
               }

               int var10 = var1[var7++] & 255;
               if (var7 >= var1.length) {
                  var1 = (byte[])((byte[])this.T.get(var11++));
                  var7 = 4;
               }

               int var9 = var1[var7++] & 255;
               if (var7 >= var1.length) {
                  var1 = (byte[])((byte[])this.T.get(var11++));
                  var7 = 4;
               }

               int var8 = var1[var7++] & 255;
               var6.a(var13, var12, Color.fromArgb(var8, var9, var10));
            }

            var7 += var5;
            if (var12 != 0 && var7 >= var1.length) {
               var1 = (byte[])((byte[])this.T.get(var11++));
               var7 -= var1.length;
               var7 += 4;
            }
         }

         com.aspose.cells.b.a.d.zh var14 = new com.aspose.cells.b.a.d.zh();
         var6.a(var14, ImageFormat.getBmp());
         return var14.o();
      }
   }

   public void setBackgroundImage(byte[] value) {
      this.T = null;
      this.U = value;
   }

   Object z() {
      return this.T != null ? this.T : this.U;
   }

   public ConditionalFormattingCollection getConditionalFormattings() {
      if (this.m == null) {
         this.m = new ConditionalFormattingCollection(this);
      }

      return this.m;
   }

   public String getActiveCell() {
      return this.J == null ? "A1" : this.J.b();
   }

   public void setActiveCell(String value) {
      if (this.J == null) {
         this.J = new zbcj(this);
      }

      this.J.a(value);
   }

   ArrayList A() {
      return this.V;
   }

   void c(ArrayList var1) {
      this.V = var1;
   }

   public CustomPropertyCollection getCustomProperties() {
      if (this.W == null) {
         this.W = new CustomPropertyCollection();
      }

      return this.W;
   }

   CustomPropertyCollection B() {
      return this.W;
   }

   public CellArea[] getPrintingPageBreaks(ImageOrPrintOptions options) throws Exception {
      this.r.getRows().a(17);
      this.r.getRows().b(1);
      this.r.c = new zkw(this.r, 16383);
      this.r.d = new zkt(this.r, 16383);

      try {
         zsx var2 = new zsx(this.c().n(), new zbuz(this.c().n()));
         var2.a(this, options);
         CellArea[] var3 = new CellArea[var2.f.size()];

         for(int var4 = 0; var4 < var2.f.size(); ++var4) {
            zasn var5 = (zasn)var2.f.get(var4);
            var3[var4] = new CellArea();
            var3[var4].StartRow = var5.c.a;
            var3[var4].StartColumn = var5.c.b;
            var3[var4].EndRow = var5.c.c;
            var3[var4].EndColumn = var5.c.d;
         }

         CellArea[] var9 = var3;
         return var9;
      } finally {
         this.r.getRows().a();
         this.r.getRows().b();
         this.r.m();
         this.r.l();
      }
   }

   public SparklineGroupCollection getSparklineGroupCollection() {
      if (this.X == null) {
         this.X = new SparklineGroupCollection(this);
      }

      return this.X;
   }

   public SmartTagSetting getSmartTagSetting() {
      if (this.Y == null) {
         this.Y = new SmartTagSetting(this);
      }

      return this.Y;
   }

   SmartTagSetting C() {
      return this.Y;
   }

   public String toString() {
      return com.aspose.cells.b.a.zv.a("Aspose.Cells.Worksheet[ {0} ]", this.getName());
   }

   znc D() {
      if (this.n == null) {
         this.n = new znc();
      }

      return this.n;
   }

   public ScenarioCollection getScenarios() {
      if (this.o == null) {
         this.o = new ScenarioCollection();
      }

      return this.o;
   }

   public Object calculateFormula(String formula) {
      byte[] var2 = this.c().x().a(-1, formula, 0, 0, 0, 64, false, true, false);
      zabd var3 = this.c().x().a((Cell)null, var2, -1);
      zyh var4 = new zyh(this.c().n());
      var4.a(1);
      Object var5 = var4.b(var3, zgy.a(this.r, 0, 0));
      return var5 instanceof zst ? zsk.a((zst)var5) : var5;
   }

   public void refreshPivotTables() throws Exception {
      int var1 = this.getPivotTables().getCount();
      PivotTable var2 = null;

      for(int var3 = 0; var3 < var1; ++var3) {
         var2 = this.getPivotTables().get(var3);
         var2.setRefreshDataFlag(true);
         var2.refreshData();
         var2.calculateData();
         var2.setRefreshDataFlag(false);
      }

   }

   public void calculateFormula(boolean recursive, boolean ignoreError, ICustomFunction customFunction) {
      if (!CalculationOptions.a) {
         CalculationOptions var23 = new CalculationOptions();
         var23.b = ignoreError;
         var23.setCustomFunction(customFunction);
         this.calculateFormula(var23, recursive);
      } else {
         boolean var19 = false;

         int var10;
         try {
            var19 = true;

            Cells var4;
            zaau var6;
            zyi var7;
            int var11;
            for(var10 = this.u.getCount() - 1; var10 > -1; --var10) {
               var4 = this.u.get(var10).getCells();
               var6 = var4.b;
               if (var6.c >= 1) {
                  var4.getRows().a(16);
                  byte var9 = 0;
                  if (var10 != this.getIndex() && !recursive) {
                     var9 = 2;
                  }

                  for(var11 = var6.b.length - 1; var11 > -1; --var11) {
                     var7 = var6.a(var11);
                     if (var7 != null) {
                        var7.a(var9);
                     }
                  }
               }
            }

            zyh var24 = new zyh(this.u.n());
            var24.a(ignoreError, customFunction);
            var4 = this.r;
            zafu var5 = var4.getRows().a;
            var6 = var4.b;

            for(var11 = var6.b.length - 1; var11 > -1; --var11) {
               var7 = var6.a(var11);
               if (var7 != null && var7.c() != 2) {
                  Cell var8 = var5.a(var7.e, var7.f);
                  if (var8 != null && var8.c.d == var7) {
                     try {
                        zabd var12 = this.u.x().a(var8);
                        if (var12 != null) {
                           var8.a((byte)1);
                           Object var13 = var24.a(var12, var8);
                           if (var8.H()) {
                              var8.b(false);
                              var8.a((byte)2);
                           } else if (var8.isArrayHeader()) {
                              zyd.a(var13, var8);
                           } else {
                              var8.a((Object)var13, (byte)2);
                           }
                        }
                     } catch (zhs var20) {
                        var24.a();
                     } catch (Exception var21) {
                        if (!ignoreError) {
                           throw new CellsException(5, "Error in calculating cell [" + this.getName() + "!" + var8.i() + "]: " + com.aspose.cells.a.c.zl.a(var21));
                        }
                     }
                  }
               }
            }

            var19 = false;
         } finally {
            if (var19) {
               for(int var15 = this.u.getCount() - 1; var15 > -1; --var15) {
                  this.u.get(var15).getCells().getRows().a();
               }

            }
         }

         for(var10 = this.u.getCount() - 1; var10 > -1; --var10) {
            this.u.get(var10).getCells().getRows().a();
         }

      }
   }

   public void calculateFormula(CalculationOptions options, boolean recursive) {
      boolean var15 = false;

      int var8;
      try {
         var15 = true;
         var8 = this.u.getCount() - 1;

         while(true) {
            Cells var3;
            zaau var5;
            zyi var6;
            if (var8 <= -1) {
               this.u.ae();
               var3 = this.r;
               zaay var17 = new zaay(this, 2, options);
               zafu var4 = var3.getRows().a;
               zfv var18 = new zfv();
               var5 = var3.b;

               for(int var11 = 0; var11 < var5.b.length; ++var11) {
                  var6 = var5.a(var11);
                  if (var6 != null && var6.c() != 2) {
                     var18.a = var6.f;
                     zfv var10 = var4.a(var6.e, var18, 4);
                     if (var10 != null && var10.d == var6) {
                        var17.b(var6);
                     } else {
                        var5.b(var11);
                     }
                  }
               }

               var15 = false;
               break;
            }

            var3 = this.u.get(var8).getCells();
            var5 = var3.b;
            if (var5.c >= 1) {
               var3.getRows().a(16);
               byte var7 = 0;
               if (var8 != this.getIndex() && !recursive) {
                  var7 = 2;
               }

               for(int var9 = var5.b.length - 1; var9 > -1; --var9) {
                  var6 = var5.a(var9);
                  if (var6 != null) {
                     var6.a(var7);
                  }
               }
            }

            --var8;
         }
      } finally {
         if (var15) {
            for(int var13 = this.u.getCount() - 1; var13 > -1; --var13) {
               this.u.get(var13).getCells().getRows().a();
            }

         }
      }

      for(var8 = this.u.getCount() - 1; var8 > -1; --var8) {
         this.u.get(var8).getCells().getRows().a();
      }

   }
}
